package com.zhu.ecology;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;

public class Browser extends JFrame {
    JPanel contentPane;
    BorderLayout borderLayoutAll = new BorderLayout();
    JLabel jLabelPrompt = new JLabel();
    JPanel jPanelMain = new JPanel();
    BorderLayout borderLayoutMain = new BorderLayout();
    JTextField textFieldURL = new JTextField();
    JEditorPane jEditorPane = new JEditorPane();

    private Sign u = new Sign();

    public Browser() {
        try {
            jbInit();
        }catch(Exception e) {
            e.printStackTrace();
        }
    }
    private void jbInit() throws Exception  {
        contentPane = (JPanel)getContentPane();
        contentPane.setLayout(borderLayoutAll);
        jPanelMain.setLayout(borderLayoutMain);
        jLabelPrompt.setText("请输入URL");
        textFieldURL.setText(""); 
        textFieldURL.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                textFieldURL_actionPerformed(e); }
        });

        jEditorPane.setEditable(false); 
        jEditorPane.addHyperlinkListener(new javax.swing.event.HyperlinkListener(){
            public void hyperlinkUpdate(HyperlinkEvent e) {
                jEditorPane_hyperlinkUpdate(e);
            }
        });
        JScrollPane scrollPane = new JScrollPane();
        scrollPane.getViewport().add(jEditorPane);
        jPanelMain.add(textFieldURL, "North");
        jPanelMain.add(scrollPane, "Center");
        contentPane.add(jLabelPrompt, "North");
        contentPane.add(jPanelMain, "Center");
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        this.setSize(new Dimension(600, 500));
        this.setTitle("迷你IE ");
        this.setVisible(true);
    }
    void textFieldURL_actionPerformed(ActionEvent e) {
        System.out.println(e.paramString());


            jEditorPane.setContentType("text/html");
        jEditorPane.setContentType("text/plain; charset=utf-8");

        jEditorPane.setText("<HTML><HEAD><LINK href=\"/css/Weaver_wev8.css\" type=text/css rel=STYLESHEET></head><BODY><table   border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>\t<td valign=\"top\">������ԭ��ٵ����������ύ��Ӧ���̣�ǩ����ǩ�ˣ�ʱ�䣺2016-01-30 13:46:10&nbsp;&nbsp;&nbsp;&nbsp;<BUTTON class=AddDoc  onclick=\"onCloseDivShowSignInfo()\">�ر�</BUTTON>\t</td></tr></TABLE></BODY></HTML>".toLowerCase());




    }
    void jEditorPane_hyperlinkUpdate(HyperlinkEvent e) {
        System.out.println(e.getURL());
        if(e.getEventType() == javax.swing.event.HyperlinkEvent.EventType.ACTIVATED) {
                jEditorPane.setText("<html><font color=red size=3>RED</font></html>");
        }
    }
    protected void processWindowEvent(WindowEvent e) { 
        super.processWindowEvent(e);
        if (e.getID() == WindowEvent.WINDOW_CLOSING) {
            System.exit(0);
        }
    }
    public static void main(String[] args) {
        new Browser();
    }
}